import json

import requests
import datetime
import sys

now = datetime.datetime.now()
orderdate = now.strftime('%Y%m%d%H%M%S')

reqeust_obj = {'BODY': '校巴', 'OPMONEY': 100, 'OUTERORDERNO': orderdate, 'SUBMCHID': "000100004000000010",
               'CFGPARA': {'merno': '10262', 'openapiurl': 'https://gw.masget.com:27373/openapi/rest',
                           'session': 'qh3ijh437g9rfr481tdz25abp4sjey4b', 'appkey': '5qmk969asexju1woskjrk3auvhl5l6si'},
               'PAYCHANNEL': 'GZRB.PAY.WEIXIN.C2B', 'returnurl': 'http://127.0.0.1:9000/testnotify'}

if __name__ == '__main__':
    channel = sys.argv[1]
    if channel == 'wxc2b':
        url = 'http://127.0.0.1:10010/hengfeng/wxc2b'
    elif channel== 'wxb2c':
        url = 'http://127.0.0.1:10010/hengfeng/wxb2c'
        auth = sys.argv[2]
        reqeust_obj["AUTHCODE"] = auth
    elif channel == 'alipayc2b':
        url = 'http://127.0.0.1:10018/huiju/alipayc2b'
    elif channel == 'quickpay':
        url = 'http://127.0.0.1:10018/huiju/quickpay'
    elif channel == 'gateway':
        url = 'http://127.0.0.1:10018/huiju/gateway'
    elif channel == 'alipayb2c':
        url = 'http://127.0.0.1:10014/alipay/alipayb2c'
        auth = sys.argv[2]
        reqeust_obj["AUTHCODE"] = auth
    elif channel == "h5":
        url = "http://127.0.0.1:10014/alipay/h5"
    elif channel == "refund":
        url = 'http://127.0.0.1:10014/alipay/refund'
        auth = sys.argv[2]
        reqeust_obj["OUTERORDERNO"] = auth
        # reqeust_obj["AUTHCODE"] = auth
    elif channel == "query":
        url = 'http://127.0.0.1:10016/zhifujia/query'
        auth = sys.argv[2]
        reqeust_obj["OUTERORDERNO"] = auth
    elif channel == 'unionpayc2b':
        url = 'http://127.0.0.1:10010/hengfeng/unionpayc2b'
        reqeust_obj['TERMINAL'] = 'CSP_AND'
    elif channel == 'qqc2b':
        url = 'http://127.0.0.1:10010/hengfeng/qqc2b'
    elif channel == "jdc2b":
        url = 'http://127.0.0.1:10010/hengfeng/jdc2b'
    elif channel == "jdb2c":
        url = 'http://127.0.0.1:10010/hengfeng/jdb2c'
    elif channel == 'wxpub':
        reqeust_obj["APPID"] = "wxb8845075e31ab25e"
        reqeust_obj["OPENID"] = "o93Ksv6m5ct8p3TI7Y1np4lHYUvA"
        url = 'http://127.0.0.1:10010/hengfeng/wxpub'
    elif channel == 'wxapp':
        reqeust_obj["APPID"] = "wxb8845075e31ab25e"
        url = 'http://127.0.0.1:10010/hengfeng/wxapp'

rsp = requests.post(url, json.dumps(reqeust_obj))
print(rsp.content)
